namespace DotNetNuke.Services.Localization
{
    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Reflection;
    using System.Runtime.CompilerServices;

    /// <summary>
    /// <para>The LocaleCollection class is a collection of Locale objects.  It stores the supported locales.</para>
    /// </summary>
    public class LocaleCollection : NameObjectCollectionBase
    {
        private DictionaryEntry _de = new DictionaryEntry();

        public void Add(string key, object value)
        {
            this.BaseAdd(key, RuntimeHelpers.GetObjectValue(value));
        }

        public void Remove(string key)
        {
            this.BaseRemove(key);
        }

        public string[] AllKeys
        {
            get
            {
                return this.BaseGetAllKeys();
            }
        }

        public Array AllValues
        {
            get
            {
                return this.BaseGetAllValues();
            }
        }

        public bool HasKeys
        {
            get
            {
                return this.BaseHasKeys();
            }
        }

        public Locale this[string key]
        {
            get
            {
                return (Locale) this.BaseGet(key);
            }
            set
            {
                this.BaseSet(key, value);
            }
        }

        public DictionaryEntry this[int index]
        {
            get
            {
                this._de.Key = this.BaseGetKey(index);
                this._de.Value = RuntimeHelpers.GetObjectValue(this.BaseGet(index));
                return this._de;
            }
        }
    }
}

